﻿using System;

using Fuse8.DomainFramework.Domain;

namespace Fuse8.DomainFramework.DataAccess
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    //todo: remove generic scope from interface
    public interface IUnitOfWorkFactory<T> : IUnitOfWorkFactory where T : class, IEntityObject, new()
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        string GenerateFactoryKey();
        
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        IUnitOfWork<T> Create(bool withTransaction);

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TMain"></typeparam>
        /// <param name="unitOfWork"></param>
        /// <returns></returns>
        IUnitOfWork<T> CreateFrom<TMain>(IUnitOfWork<TMain> unitOfWork) where TMain : class, IEntityObject;

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        IUnitOfWork<T> Get(bool withTransaction);

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TMain"></typeparam>
        /// <param name="unitOfWork"></param>
        void UseFrom<TMain>(IUnitOfWork<TMain> unitOfWork) where TMain : class, IEntityObject;

        /// <summary>
        /// 
        /// </summary>
        void CommitTransaction();

        /// <summary>
        /// 
        /// </summary>
        void RollbackTransaction();
    }
}
